var app = getApp()
Component({
  properties:{
    count:{
      type:String,
      value:""
    }
  },
  data: {
    show:2,
    selected:null,
    "backgroundColor": "#fff",
    "color": "#333",
    "selectedColor": "#005858",
    "list": [{
        "pagePath": "../../pages/home/home",
        "iconPath": "/images/home.png",
        "selectedIconPath": "/images/home-checked.png",
        "text": "首页",
        "isshow":true
      },
      {
        "pagePath": "../../pages/shopping/shopping",
        "iconPath": "/images/shop.png",
        "selectedIconPath": "/images/shop-checked.png",
        "text": "商城",
        "isshow":false
      },
      {
        "pagePath": "../../pages/myinfo/myinfo",
        "iconPath": "/images/my.png",
        "selectedIconPath": "/images/my-checked.png",
        "text": "我的",
        "isshow":true
      }
    ]
  },
  attached() {
    var show
    var _this = this
    
    if (!wx.getStorageSync('setting_status')) {
      this.GetUserEntity().then((res) => {
        if (res.data.code == 2000) {
            this.setData({
              show:res.data.data[0].status
            })
            if(this.data.show==1){
              var ppp="list[1].isshow"
              this.setData({
                [ppp]:true
              })
            }
        }
      }).catch((res) => {
        console.log(res)
      })
    } else {
       this.setData({
        show:wx.getStorageSync('setting_status')
      })
      if(this.data.show==1){
        var ppp="list[1].isshow"
        this.setData({
          [ppp]:true
        })
      }
    }
   
    
   
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      this.setData({
        selected:null
      })
      wx.switchTab({url})
    },
    GetUserEntity: function () {
      return new Promise(function (resolve, reject) {
        wx.request({
          url: "http://api_dev.wanxikeji.cn/api/setting",
          data: {
            token: wx.getStorageSync('token')
          },
          success: (res) => {
            let result = res;
            resolve(result);
          },
          fail: () => {
            reject("系统异常，请重试！")
          }
        })
      })
    },
  },
})